<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .outer {
      position: relative;
      width: 600px;
      height: 600px;
      background-color: #bfa;
      margin: 0 auto;
    }

    .inner {
      /* 这种方式不需要知道w和h */
      position: absolute;
      background-color: tomato;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  </style>
</head>
<body>
  <div class="outer">
    <div class="inner">aaaaaaasssssssssssssssssssssss</div>
  </div>
</body>
</html>